<template>
	<view>
		
		<view class="statisticsWorker_box">
			<view class="statsUser_con">
				<view class="userAvatar">
					<image :src="memberTotal.userInfo.header_img" mode=""></image>
				</view>
				<view class="userName">{{memberTotal.userInfo.name}}</view>
				<view class="userStatus">
					{{memberTotal.quit==0?'在职':'离职'}}
				</view>
			</view>
			<view class="projectStats_con">
				<view class="statsList_con">
					<view class="statsItem">
						<view class="statsLabel">总工</view>
						<view class="statsMoney">
							{{memberTotal.num}}
							<text class="overHout" v-if="memberTotal.overtime_hour>0">+{{memberTotal.overtime_hour}}</text>
							<text class="overHout" v-if="memberTotal.overtime_hour>0">H</text>
						</view>
					</view>
					<view class="statsLine"></view>
					<view class="statsItem">
						<view class="statsLabel">总工资(元)</view>
						<view class="statsMoney">
							{{memberTotal.total_money}}
						</view>
					</view>
				</view>
				<view class="statsMoney_con">
					<image src="/static/moneyIcon.png" mode=""></image>
					<text>已支付(元)：{{memberTotal.yes_money}}，剩余工资(元)：{{memberTotal.no_money}}</text>
				</view>
			</view>
		</view>
		
		<!-- 工地统计 -->
		<view style="width: 100%; height: 30rpx;"></view>
		<view class="tableOutBox">
			<view class="tableInBox">
				<view class="tableTr">
					<view class="tableTd ">工地名称</view>
					<view class="tableTd tableTd30">合计</view>
					<view class="tableTd tableTd30">工资</view>
					<view class="tableTd tableTd15">状态</view>
				</view>
				
				<view class="tableTr tableTr2" v-for="(item,index) in memberList" 
							:key="index" >
					<view class="tableTd ">
						<view class="kongItem"></view>
						{{item.projectInfo.name}}
					</view>
					<view class="tableTd tableTd2 tableTd30" >
						<view class="kongItem"></view>
						<view class="tableTdItem">
							总<text class="ziOne"></text>工:<text class="color1">{{item.total_num}}{{item.work_type==0?'工':'小时'}}</text>
						</view>
						<view class="tableTdItem" v-if="item.overtime_hour>0">
							加<text class="ziOne"></text>班:<text class="color1">{{item.overtime_hour}}H</text>
						</view>
						<view class="tableTdItem">
							总工资:<text class="color1">{{item.total_money}}</text>
						</view>
					</view>
					<view class="tableTd tableTd2 tableTd30" >
						<view class="kongItem"></view>
						<view class="tableTdItem">
							已支付:<text class="color2">{{item.total_borrow}}</text>
						</view>
						<view class="tableTdItem">
							剩余工资:<text class="color2">{{item.no_money}}</text>
						</view>
					</view>
					<view class="tableTd  tableTd3 tableTd15">{{item.history==0?'进行中':'已完工'}}</view>
				</view>
			</view>
		</view>
		
		
		<!-- <view class="workerList_con">
			<view class="workerItem" v-for="(item,index) in memberList" :key="index">
				<view class="workerInfo">
					<view class="projectName">
						<image src="/static/projectIcon.png" mode=""></image>
						{{item.projectInfo.name}}
					</view>
					<view class="settleDoing" v-if="item.history==0">进行中</view>
					<view class="settleEnd" v-if="item.history==1">已完工</view>
				</view>
				<view class="workerStatistics">
					<view class="workerLi">
						<view class="workerMoney digitFont">{{item.total_num}}</view>
						<view class="workerDesc">总工</view>
					</view>
					<view class="workerLi">
						<view class="workerMoney digitFont">{{item.total_money}}</view>
						<view class="workerDesc">总工资</view>
					</view>
					<view class="workerLi">
						<view class="workerMoney digitFont">{{item.total_borrow}}</view>
						<view class="workerDesc">已支付</view>
					</view>
					<view class="workerLi">
						<view class="workerMoney digitFont">{{item.no_money}}</view>
						<view class="workerDesc">剩余工资</view>
					</view>

				</view>
			</view>
		</view> -->
		
		
		<view style="width: 100%; height: 200rpx;">
			
		</view>
		<!-- 下载excel -->
		<view class="downloadExcel" v-if="user_id>0"
			@click="goPage('./excelExport?type=2&user_id='+user_id)">
			<image src="/static/img/excel.png" mode=""></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user_id: '',
				memberList: [],
				memberTotal: {},
			}
		},
		onLoad(e) {
			console.log(e)
			var _this = this;
			if (e.user_id) {
				_this.user_id = e.user_id;
			}
			_this.getByMember();
		},
		methods: {
			// 获取按工人详情
			getByMember() {
				var _this = this;
				_this.$u.get('/api/project.monthdata/memberByProject', {
					user_id: _this.user_id
				}).then(res => {
					uni.hideLoading();
					_this.memberList = res.data;
					_this.memberTotal = res.extend;
				}).catch(res => {
					console.log(res);
				})
			},


			// 页面跳转
			goPage(url) {
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}
</style>
<style scoped lang="scss">
	.statisticsWorker_box{
		padding: 0 30rpx;
		background-color: $uni-color-white;
	}
	
	.statsUser_con {
		padding: 30rpx 0;
		overflow: hidden;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.userAvatar {
		width: 80rpx;
		height: 80rpx;
		border-radius: 10rpx;
		overflow: hidden;
	}
	
	.userAvatar image {
		width: 100%;
		height: 100%;
	}
	
	.userName {
		flex: 2;
		font-size: 28rpx;
		font-weight: bold;
		color: $uni-color;
		margin: 0 20rpx;
	}
	
	.userStatus {
		width: 100rpx;
		height: 42rpx;
		line-height: 42rpx;
		text-align: center;
		font-size: 24rpx;
		color: #FFC30B;
		background: #fffaeb;
		border-radius: 8rpx;
		overflow: hidden;
	}
	
	.wageMoney_con {
		padding-bottom: 30rpx;
		overflow: hidden;
		display: flex;
		align-items: center;
	}
	
	.wageMoney_con image {
		width: 30rpx;
		height: 30rpx;
	}
	
	.wageMoney_con text {
		font-size: 28rpx;
		color: $uni-color;
		margin-left: 20rpx;
	}
	
	.projectStats_con {
		overflow: hidden;
	}
	
	.statsList_con {
		height: 200rpx;
		background: #f0f6ff;
		border: 2rpx solid #cce0ff;
		border-radius: 10rpx 10rpx 0 0;
		box-sizing: border-box;
		overflow: hidden;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.projectStats_con .statsItem {
		flex: 1;
		text-align: center;
	}
	
	.projectStats_con .statsLabel {
		font-size: 28rpx;
		color: #8B8A90;
	}
	
	.projectStats_con .statsMoney {
		font-size: 54rpx;
		font-weight: bold;
		color: #000;
		margin-top: 20rpx;
	}
	
	.projectStats_con .statsMoney text {
		font-size: 28rpx;
	}
	
	.projectStats_con .statsLine {
		width: 2rpx;
		height: 60rpx;
		background-color: #CCE0FF;
	}
	
	.projectStats_con .statsMoney_con {
		height: 90rpx;
		padding: 0 30rpx;
		background: #327fe8;
		border-radius: 0 0 10rpx 10rpx;
		box-sizing: border-box;
		overflow: hidden;
		display: flex;
		align-items: center;
	}
	
	.projectStats_con .statsMoney_con image {
		width: 30rpx;
		height: 30rpx;
	}
	
	.projectStats_con .statsMoney_con text {
		font-size: 28rpx;
		color: #fff;
		margin-left: 20rpx;
	}
	
	// 工地统计
	.workerList_con {
		padding: 0 30rpx;
	}

	.workerItem {
		overflow: hidden;
	}

	.workerInfo {
		padding: 30rpx 0;
		overflow: hidden;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.projectName {
		font-size: 28rpx;
		font-weight: bold;
		color: #000;
		margin-right: 20rpx;
		float: left;
		width: 400rpx;
		line-height: 34rpx;
	}

	.projectName image {
		width: 34rpx;
		height: 34rpx;
		vertical-align: top;
		margin: 0rpx 10rpx 0 0;
	}

	.settleDoing {
		width: 100rpx;
		height: 42rpx;
		line-height: 42rpx;
		text-align: center;
		font-size: 24rpx;
		color: #FF4241;
		background: #FFEBEB;
		border-radius: 8rpx;
		overflow: hidden;
	}

	.settleEnd {
		width: 100rpx;
		height: 42rpx;
		line-height: 42rpx;
		text-align: center;
		font-size: 24rpx;
		color: #327FE8;
		background: #EBF3FF;
		border-radius: 8rpx;
		overflow: hidden;
	}

	.workerStatistics {
		padding: 30rpx 0;
		background: #EBF3FF;
		border-radius: 10rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	.workerLi {
		flex: 1;
		text-align: center;
	}

	.workerMoney {
		font-size: 40rpx;
		color: #000;
	}

	.workerDesc {
		font-size: 24rpx;
		color: #999;
		margin-top: 20rpx;
	}
	
	
	
	//表格
	.tableOutBox{
		background-color: #dae1e8;
		border-left: 2rpx solid #e2e2e2;
		border-top: 2rpx solid #e2e2e2;
		box-sizing: border-box;
		width: 690rpx;
		margin: 0rpx auto;
		border-radius: 10rpx;
		overflow: hidden;
	}
	
	.tableInBox{
		background-color: #fff;
		border-radius: 10rpx;
	}
	.tableTr{
		height: 90rpx;
		line-height: 90rpx;
		overflow: hidden;
		background-color: #f7fbfe;
		border-bottom: 2rpx solid #e2e2e2;
	}
	.tableTr2{
		min-height: 170rpx;
		line-height: 50rpx;
		text-align: left;
		font-size: 28rpx;
		font-weight: 400;
		box-sizing: border-box;
	}
	.tableTr:nth-child(2n){
		background-color: #ffff;
	}
	.tableTd{
		width: 25%;
		height: 100%;
		text-align: center;
		padding-left: 10rpx;
		float: left;
		font-size: 26rpx;
		font-weight: bold;
		border-right: 2rpx solid #e2e2e2;
	}
	.tableTd2{
		text-align: left;
		padding-left: 10rpx;
		font-weight: 400;
		font-size: 26rpx;
		color: #333;
	}
	.tableTd3{
		text-align: center;
		line-height: 170rpx;
		color: #327fe8;
		font-size: 26rpx;
		padding-left: 0rpx;
	}
	.color1{
		color: #ff6600;
	}
	.color2{
		color: #35c700;
	}
	
	.tableTd10{
		width: 10%;
	}
	.tableTd15{
		width: 15%;
	}
	.tableTd20{
		width: 20%;
	}
	.tableTd30{
		width: 30%;
	}
	.tableTd35{
		width: 35%;
	}
	.kongItem{
		width: 100%;
		height: 10rpx;
	}
	.ziOne{
		padding-left: 28rpx;
	}
	
	
	// 下载excel
	.downloadExcel {
		position: fixed;
		right: 30rpx;
		bottom: 30rpx;
	}
	
	.downloadExcel image {
		width: 100rpx;
		height: 100rpx;
	}
	
	.overHout{
		font-size: 28rpx;
		color: #f00;
	}
</style>
